package com.cq.hd.common.enums.biz;

import lombok.Getter;

/**
 * @description: 红包类型：1新用户红包 2积分兑换的优惠券
 */
public enum RedPacketTypeEnum {

    NEW_USER(1, "新用户红包"),
    POINTS_COUPON(2, "积分兑换的优惠券"),
    ;

    @Getter
    private final Integer value;

    @Getter
    private final String name;

    RedPacketTypeEnum(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    public static RedPacketTypeEnum typeOf(Integer value) {
        RedPacketTypeEnum[] values = RedPacketTypeEnum.values();
        for (RedPacketTypeEnum v : values) {
            if (v.value.equals(value)) {
                return v;
            }
        }
        return null;
    }

    public static RedPacketTypeEnum typeOf(String name) {
        RedPacketTypeEnum[] values = RedPacketTypeEnum.values();
        for (RedPacketTypeEnum v : values) {
            if (v.name.equals(name)) {
                return v;
            }
        }
        return null;
    }

}
